package arrAndstr;

import java.util.*;

/*
    380. O(1) 时间插入、删除和获取随机元素
 */
public class T380 {

    public static void main(String[] args) {

        Set<Integer> set = new HashSet<>();
        set.add(3);
        System.out.println(set.contains(3));
    }

    class RandomizedSet {

        private List<Integer> list;
        private Set<Integer> set;
        private Random random = new Random();

        public RandomizedSet() {
            this.list = new ArrayList<>();
        }

        public boolean insert(int val) {
            if (list.contains(val)) {
                return false;
            }
            list.add(val);
            return true;
        }

        public boolean remove(int val) {
            return list.remove((Integer) val);
        }

        public int getRandom() {
            return list.get(random.nextInt(list.size()));
        }
    }
}


